package kr.etcsoft.examples.binding.viewer.table;

import kr.etcsoft.examples.binding.model.Person;
import kr.etcsoft.examples.binding.model.ViewModel;

import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.jface.databinding.viewers.ViewerSupport;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.part.ViewPart;

public class NoContentAndLabelProviderView extends ViewPart {
    private ViewModel viewModel = new ViewModel();
    private Table committers;

    public NoContentAndLabelProviderView() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public void createPartControl(Composite parent) {
        committers = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
        committers.setHeaderVisible(true);
        committers.setLinesVisible(true);

        TableColumn column = new TableColumn(committers, SWT.NONE);
        column.setText("name");

        TableViewer peopleViewer = new TableViewer(committers);

        ViewerSupport.bind(peopleViewer, new WritableList(viewModel
                .getPeople(), Person.class), BeanProperties.value(
                Person.class, "name"));

        column.pack();
    }

    @Override
    public void setFocus() {
        // TODO Auto-generated method stub

    }
}
